package br.net.woodstock.tickettoride.orm;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import br.net.woodstock.rockframework.persistence.validator.jee.Reference;

@Entity
@Table(name = "ttr_ticket_destination")
public class TicketDestination extends AbstractIntegerEntity {

	private static final long	serialVersionUID	= -4022626248688938186L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ticket_destination_id", unique = true)
	private Integer				id;

	@Column(name = "ticket_status", nullable = false)
	@Enumerated(EnumType.ORDINAL)
	@NotNull
	private TicketStatus		status;

	@ManyToOne(optional = false, fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "application_id", referencedColumnName = "application_id", nullable = false)
	@NotNull
	@Reference
	private Application			application;

	@ManyToOne(optional = false, fetch = FetchType.EAGER, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "ticket_id", referencedColumnName = "ticket_id", nullable = false)
	@NotNull
	@Reference
	private Ticket				ticket;

	public TicketDestination() {
		super();
	}

	public TicketDestination(final Integer id) {
		super();
		this.id = id;
	}

	@Override
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final Integer id) {
		this.id = id;
	}

	public TicketStatus getStatus() {
		return this.status;
	}

	public void setStatus(final TicketStatus status) {
		this.status = status;
	}

	public Application getApplication() {
		return this.application;
	}

	public void setApplication(final Application application) {
		this.application = application;
	}

	public Ticket getTicket() {
		return this.ticket;
	}

	public void setTicket(final Ticket ticket) {
		this.ticket = ticket;
	}

}
